﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Kaskelot.Services.Model;

namespace Stockholm.SOA.Kaskelot.WCF.ServiceImplementation.Mapping
{
	public static class KursExtensions
	{
		public static DataContracts.Kurs ToContract(this Kurs entity)
		{
			DataContracts.Kurs b = new DataContracts.Kurs();

			CopyFromEntity(entity, b, false);

			return b;
		}

		public static DataContracts.Kurs ToMinimalContract(this Kurs entity)
		{
			DataContracts.Kurs b = new DataContracts.Kurs();

			CopyFromEntity(entity, b, true);

			return b;
		}

		public static Kurs ToEntity(this DataContracts.Kurs b)
		{
			Kurs entity = new Kurs();

			CopyToEntity(b, entity);

			return entity;
		}

		public static void UpdateEntity(this Kurs entity, DataContracts.Kurs Kurs)
		{
			CopyToEntity(Kurs, entity);
		}

		private static void CopyFromEntity(Kurs from, DataContracts.Kurs to, bool minimal)
		{
			to.Id = from.Id;
			to.ValId = from.ValId;

			to.Andrad = from.Andrad;
			to.AndradAv = from.AndradAv;
			to.Skapad = from.Skapad;
			to.SkapadAv = from.SkapadAv;

			to.Beskrivning = from.Beskrivning;
			to.KursInfo = from.KursInfo;
		}

		private static void CopyToEntity(DataContracts.Kurs from, Kurs to)
		{
			to.Id = from.Id;
			to.ValId = from.ValId;

			to.Andrad = from.Andrad;
			to.AndradAv = from.AndradAv;
			to.Skapad = from.Skapad;
			to.SkapadAv = from.SkapadAv;

			to.Beskrivning = from.Beskrivning;
			to.KursInfo = from.KursInfo;
		}
	}
}
